package com.controller.admin;

import com.entity.Classroom;
import com.service.IClassRoomService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * 教室
 *
 * @Author zhangfoshou
 * @Since 2016/1/9
 */
@Controller
@RequestMapping("/classRoom")
public class ClassroomController {
    @Resource
    private IClassRoomService classRoomService;

    /**
     * 更新
     *
     * @param classroom 教室
     * @return    
     * @author foshou.zhang
     */
    @RequestMapping("/update")
    public String updateClassroom(Classroom classroom, Integer id) {
        classroom.setId(id);
        classRoomService.update(classroom);
        System.out.println("classroom = " + classroom);
        return "redirect:/maintain/classRoomMaintain.html";
    }

    /**
     * 编辑
     *
     * @param id       id
     * @param modelMap
     * @return
     * @author foshou.zhang
     */
    @RequestMapping("/edit")
    public String edit(Integer id, ModelMap modelMap) {
        Classroom classroom = classRoomService.selectById(id);
        modelMap.addAttribute("c", classroom);
        return "classRoom/edit";
    }
}
